package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.pojo.OrganAddress;
import com.itheima.service.OrganAddressService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 机构地址管理
 */
@RestController
@RequestMapping("/organ")
public class OrganAddressController {

    @Reference
    private OrganAddressService organAddressService;

    //根据坐标查询机构
    @RequestMapping("/findOrgans")
    public Result findOrgans(String lng, String lat){
        try {
            List<OrganAddress> addresses = organAddressService.findOrgans(lng, lat);
            return new Result(true, MessageConstant.QUERY_ORGAN_ADDRESS_SUCCESS, addresses);
        }catch (Exception e){
            return new Result(false, MessageConstant.QUERY_ORGAN_ADDRESS_FAIL);
        }
    }
}
